package NGLR;

import GameLogic.EntityModel;
import org.lwjgl.BufferUtils;

import java.nio.FloatBuffer;
import java.nio.IntBuffer;


class Model {
    public FloatBuffer vertex_array;
    public FloatBuffer texture_coordinate_array;
    public FloatBuffer vertex_colour_array;
    public IntBuffer texures_IDs;

    Model(EntityModel model){
        vertex_array = BufferUtils.createFloatBuffer(model.vertices.length);
        vertex_array.put(model.vertices);
        vertex_array.flip();
        if((model.texture_path != null) && (model.texture_coordinates == null))
             texures_IDs = BufferUtils.createIntBuffer(model.frames);
        if((model.texture_path == null) || (model.texture_coordinates == null))
            texture_coordinate_array = null;
        else {
            texture_coordinate_array = BufferUtils.createFloatBuffer(model.texture_coordinates.length);
            texture_coordinate_array.put(model.texture_coordinates);
            texture_coordinate_array.flip();
            texures_IDs = BufferUtils.createIntBuffer(model.frames);
        }
        vertex_colour_array = BufferUtils.createFloatBuffer(model.vertex_colour.length);
        vertex_colour_array.put(model.vertex_colour);
        vertex_colour_array.flip();
    }

}
